<%@ include file="../common.jsp"%>

<script type="text/javascript">
	$(document).ready(
		
			function() {
				$("#docType").attr("action",'<c:url value="/saveDocTypeNewDetails.htm"></c:url>');
				$("#dtName").focus();
			});
		
</script>

<c:choose>
	<c:when test="${size eq 0}">
		No Records Found.
	</c:when>
	<c:otherwise>
		<form name="submitTypeDetailsToEdit" id="submitTypeDetailsToEdit">
			<div style="width: 40%;">
				<table class="viewDetails">
					<tr class="adminTableMainHeaderColor tableChildHeaderFont">
						<th colspan="3" align="center"> LIST OF DOCUMENT TYPE(S) </th>
					</tr>
					<tr class="heading" align="center">
						<th> Select </th>
						<th> Code </th>
						<th> Name </th>
					</tr>	
				
					<c:forEach items="${docTypeMap}" var="docTypeMap" varStatus="loop">
						<c:set var="tabColor" value="odd"></c:set>
					     	<c:if test="${(loop.index % 2) eq 0}">
					        	<c:set var="tabColor" value="even"></c:set>
					        </c:if>
					<tr class="${tabColor}">
						<td align="center"> <input type="radio" id="radio${index.index}" name="radio" value="${docTypeMap.value.dtId},${docTypeMap.value.dtCode},${docTypeMap.value.dtName}"/> </td>
						<td> ${docTypeMap.value.dtCode} </td>
						<td> ${docTypeMap.value.dtName} </td>
					</tr>	
					</c:forEach>	
				</table>
				<table>
					<tr align="left">
						<td colspan="5">
							<input class="formButton ui-corner-all" type="button" value="SELECT" onclick="submitTypeDetailsForEditing();" />
						</td>
					</tr>
				</table>
			</div>
		</form>
		
		<c:if test="${resultOfSave}">
			Operation Done Successfully.
		</c:if>
		
		<br>
		<hr/>
		<br>
		
		<form:form commandName="documentTypeDTO" id="docType">
						<form:hidden path="dtId" id="dtId"/>
			<table class="adminFilterTable">
				<tr class="tableChildHeaderColor">
					<th colspan="5" align="center"> EDIT DOCUMENT TYPE </th>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel"> Code </td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formField"> <form:input path="dtCode" id="dtCode" readonly="true"/> 
						<form:errors path="dtCode" cssClass="errorMsg" /> </td>
					<td class="spacingColumnWidthLess"></td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel"> Name* </td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formField"> <form:input path="dtName" id="dtName"/> 	
						<form:errors path="dtName" cssClass="errorMsg" /> </td>
					<td class="spacingColumnWidthLess"></td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td></td>
					<td class="spacingColumnWidthLess"></td>
					<td colspan="2" align="center">
						<input class="formButton ui-corner-all" type="button" value="UPDATE" onclick="javascript:addEntity('docType')"></input>
					</td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
			</table>
		</form:form>
		
	</c:otherwise>
</c:choose>